﻿<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script>
        let arr = [1, 2, 3, 4];
        //let a = arr.indexOf(3);
        //console.log(a);
        //let indexOf1 = function () {
        //    let unm = 0;
        //    for (var i = 0; i < arr.length; i++) {
        //        if (arguments[0]==arr[i]) {
        //            unm = i;
        //            break;
        //        } else {
        //            unm = -1;
        //        }
        //    }
        //    return unm;
        //}
        //console.log(indexOf1(4));
        Array.prototype.indexOf1 = function () {
           /* let unm = 0;*/
            for (var i = 0; i < this.length; i++) {
                if (arguments[0] == this[i]) {
                    //unm = i;
                    //break;
                    return i;
                } else {
                    //unm = -1;
                }
            }
            return -1;
        }
        let a = arr.indexOf1(3);
        console.log(a);



        Array.prototype.lastindexOf1 = function () {
           for (var i = this.length-1; i >= 0; i++) {
                if (arguments[0] == this[i]) {
                   return i;
                } 
            }
            return -1;
        }
        let b = arr.lastindexOf1(4);
        console.log(b);
    </script>
</body>
</html>